Skip to content

fix: fall back to getRandomValues when crypto.randomUUID is unavailable - #6

Draft
Alex20923 wants to merge 1 commit into
vmkteam:masterfrom
Alex20923:fix/crypto-randomuuid-insecure-context
Draft

fix: fall back to getRandomValues when crypto.randomUUID is unavailable#6
Alex20923 wants to merge 1 commit into
vmkteam:masterfrom
Alex20923:fix/crypto-randomuuid-insecure-context

Conversation

@Alex20923

Copy link
Copy Markdown

crypto.randomUUID() is only exposed in secure contexts (HTTPS or http://localhost). When SMDBox is served over plain HTTP on an IP address (e.g. straight from a JSON-RPC backend during development), crypto.randomUUID is undefined and invoking a method throws
"TypeError: crypto.randomUUID is not a function" on submit, crashing the app.

Add a randomUUID() helper that uses crypto.randomUUID when available and falls back to crypto.getRandomValues (which is exposed in insecure contexts too) otherwise. Route all six call sites through it and add unit tests covering the insecure-context fallback.

@Alex20923
Alex20923 force-pushed the fix/crypto-randomuuid-insecure-context branch from d1a4171 to 8a96d97 Compare July 22, 2026 11:19
crypto.randomUUID() is only exposed in secure contexts (HTTPS or
http://localhost). When SMDBox is served over plain HTTP on an IP address
(e.g. straight from a JSON-RPC backend during development), crypto.randomUUID
is undefined and invoking a method throws
"TypeError: crypto.randomUUID is not a function" on submit, crashing the app.

Add a randomUUID() helper that uses crypto.randomUUID when available and falls
back to crypto.getRandomValues (which is exposed in insecure contexts too)
otherwise. Route all six call sites through it and add unit tests covering the
insecure-context fallback.
@Alex20923
Alex20923 force-pushed the fix/crypto-randomuuid-insecure-context branch from 8a96d97 to e43c291 Compare July 22, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant